﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Light.Utility
{
    /// <summary>
    /// 导入导出字段属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Property)]
    public class ImportFieldAttribute : Attribute
    {
        /// <summary>
        /// 列名
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 自定义类型的对象是否关联导出
        /// </summary>
        public bool IsRelatived { get; private set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Ordinal { get; private set; }

        /// <summary>
        /// 此构造函数用于 类 上标签， 属性上请有有参构造函数
        /// </summary>
        public ImportFieldAttribute()
        {
            Ordinal = -1;
        }

        /// <summary>
        /// 导入导出字段
        /// </summary>
        /// <param name="name">字段名，对应文件中的列名</param>
        public ImportFieldAttribute(string name)
        {
            Name = name;
        }
        /// <summary>
        /// 导入导出字段
        /// </summary>
        /// <param name="name">字段名，对应文件中的列名</param>
        /// <param name="isRelative">是否关联导出</param>
        public ImportFieldAttribute(string name, bool isRelative)
            : this(name)
        {
            IsRelatived = isRelative;
        }

        /// <summary>
        /// 导入导出字段/属性
        /// </summary>
        /// <param name="name">字段名，对应文件中的列名</param>
        /// <param name="isRelative">是否关联导出</param>
        /// <param name="ordinal">排序值，值越小越靠前</param>
        public ImportFieldAttribute(string name, bool isRelative, int ordinal)
            : this(name, isRelative)
        {
            Ordinal = ordinal;
        }

        /// <summary>
        /// 导入导出字段/属性
        /// </summary>
        /// <param name="name">字段名，对应文件中的列名</param>
        /// <param name="ordinal">排序值，值越小越靠前</param>
        public ImportFieldAttribute(string name, int ordinal)
            : this(name)
        {
            Ordinal = ordinal;
        }


    }
}
